package com.era.act.dis;

import java.util.List;

import org.omg.CORBA.Request;

import com.era.entity.Classes;
import com.era.entity.Comment;
import com.era.entity.NewsInfo;
import com.era.srv.ClassSrv;
import com.era.srv.CommentSrv;
import com.era.srv.NewsSrv;
import com.opensymphony.xwork2.ActionSupport;

public class MainTextAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private NewsSrv newsSrv;
	private NewsInfo newsInfo;
	private Integer newsId;
	private ClassSrv classSrv;
	private Classes cla;
	private Integer classId;
	private CommentSrv commentSrv;
	private List commentList;
	private Comment comment;
	private String content;
	private String comPerson;

	
	
	
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public NewsSrv getNewsSrv() {
		return newsSrv;
	}
	public void setNewsSrv(NewsSrv newsSrv) {
		this.newsSrv = newsSrv;
	}
	
	public NewsInfo getNewsInfo() {
		return newsInfo;
	}
	public void setNewsInfo(NewsInfo newsInfo) {
		this.newsInfo = newsInfo;
	}
	public Integer getNewsId() {
		return newsId;
	}
	public void setNewsId(Integer newsId) {
		this.newsId = newsId;
	}
	
	public ClassSrv getClassSrv() {
		return classSrv;
	}
	public void setClassSrv(ClassSrv classSrv) {
		this.classSrv = classSrv;
	}
	public Classes getCla() {
		return cla;
	}
	public void setCla(Classes cla) {
		this.cla = cla;
	}
	public Integer getClassId() {
		return classId;
	}
	public void setClassId(Integer classId) {
		this.classId = classId;
	}
	
	
	public CommentSrv getCommentSrv() {
		return commentSrv;
	}
	public void setCommentSrv(CommentSrv commentSrv) {
		this.commentSrv = commentSrv;
	}
	public List getCommentList() {
		return commentList;
	}
	public void setCommentList(List commentList) {
		this.commentList = commentList;
	}
	
	
	public Comment getComment() {
		return comment;
	}
	public void setComment(Comment comment) {
		this.comment = comment;
	}

	public String execute() throws Exception{
		newsInfo=newsSrv.getMainText(newsId);
		System.out.println(newsId);
		cla=classSrv.getCla(classId);
		commentList=commentSrv.getCom(newsId);
		return SUCCESS;
	}
	
	public String insert() throws Exception{
		if(comPerson.equals("")||comPerson==null){
			return ERROR;
		}else{
		comment=new Comment(newsId,comPerson,content);
		commentSrv.insComment(comment);
		return SUCCESS;
		}
	}
	public String getComPerson() {
		return comPerson;
	}
	public void setComPerson(String comPerson) {
		this.comPerson = comPerson;
	}
	
}
